package com.shop.controller;


import com.shop.common.result.Result;
import com.shop.common.result.util.ResultModel;
import com.shop.service.MerchantService;
import com.shop.vo.commodity.AddCommodityVo;
import com.shop.vo.AddMerchantVo;
import com.shop.vo.commodity.UpdateCommodityVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 商户表 前端控制器
 * </p>
 *
 * @author 靳 旺
 * @since 2021-01-29
 */
@RestController
@Api(tags = "商户前端控制器")
@RequestMapping("/merchant-do")
public class MerchantController {
    @Autowired
    private MerchantService merchantService;

    @RequestMapping("add")
    @ApiOperation(value = "添加商户",notes = "靳旺")
    public ResultModel add(@RequestBody @Valid AddMerchantVo addMerchantVo, BindingResult result) throws Exception {
        if (result.hasErrors())  return Result.errorResultModel(result.getAllErrors());
        return merchantService.addMerchant(addMerchantVo);
    }

}
